/*
 * @Description:
 * @Author: fhw
 * @Date: 2023-03-26 15:05:23
 */
import { ApiProperty } from '@nestjs/swagger';
import { BaseEntity, PaginatedResult } from 'src/common/entities/entities';
import { Status } from 'src/dictionaries/index.enum';
import { Column, Entity, ManyToMany, OneToMany } from 'typeorm';
import { MovieEntity } from '../../movies/entities/movie.entity';
@Entity('category')
export class CategoryEntity extends BaseEntity {
  /** 分类名称 */
  @ApiProperty({ example: 'name', description: '分类名称' })
  @Column({
    type: 'varchar',
    comment: '分类名称',
    length: 255,
  })
  name: string;
  /** 是否启用 */
  @ApiProperty({
    enum: Status,
    example: Status.ENABLED,
    description: '是否启用',
  })
  @Column({
    type: 'enum',
    enum: Status,
    default: Status.ENABLED,
  })
  status: Status;
  /** 排序 */
  @ApiProperty({ example: 'sort', description: '排序' })
  @Column({
    type: 'tinyint',
    comment: '排序',
    default: 0,
  })
  sort: number;
  /** 语言 */
  @ApiProperty({ example: 'lang', description: '语言' })
  @Column({
    type: 'varchar',
    comment: '语言',
    length: 50,
  })
  lang: string;

  @ManyToMany(() => MovieEntity, (movie) => movie.category)
  movies: MovieEntity[];
  /** 创建人 */
  @ApiProperty({ example: 'createById', description: '创建人' })
  @Column({ type: 'int', comment: '创建人' })
  createById: number;
  /** 更新人 */
  @ApiProperty({ example: 'updateById', description: '更新人' })
  @Column({ type: 'int', comment: '更新人', nullable: true })
  updateById: number;

}
export class CategoryResult extends PaginatedResult {
  @ApiProperty({ example: 'data', description: 'data' })
  data: CategoryEntity;
}